{include file="public/layout" /}
<body class="bodystyle" style="overflow: auto;min-width:auto;">
<div id="toolTipLayer" style="position: absolute; z-index: 9999; display: none; visibility: visible; left: 95px; top: 573px;"></div>
<div id="append_parent"></div>
<div id="ajaxwaitid"></div>
<div class="page min-hg-c-i" style="min-width: auto;box-shadow:none;padding-bottom: 0px;">
    <form class="form-horizontal" id="post_form" action="{:U('ArchivesFlag/add')}" method="post">        
        <div class="ncap-form-default">
            <dl class="row">
                <dt class="tit">
                    <label for="flag_name"><em>*</em>属性名称</label>
                </dt>
                <dd class="opt">
                    <input type="text" name="flag_name" value="{$info.flag_name|default=''}" id="flag_name" class="input-txt">
                    <span class="err"></span>
                    <p class="notic"></p>
                </dd>
            </dl>
            <dl class="row">
                <dt class="tit">
                    <label for="flag_attr"><em>*</em>属性值</label>
                </dt>
                <dd class="opt">
                    <input type="text" name="flag_attr" value="{$info.flag_attr|default=''}" id="flag_attr" class="input-txt">
                    <span class="errorMsg"></span>
                    <p class="notic2">2个及以上小写字母</p>
                </dd>
            </dl>
            <dl class="row">
                <dt class="tit">
                    <label for="sort_order">排序</label>
                </dt>
                <dd class="opt">
                    <input type="text" name="sort_order" value="{$info.sort_order|default='100'}" id="sort_order" class="input-txt">
                    <span class="err"></span>
                    <p class="notic">越小越靠前</p>
                </dd>
            </dl>
            <div class="bot"><a href="JavaScript:void(0);" onclick="checkForm();" class="ncap-btn-big ncap-btn-green" id="submitBtn">确认提交</a></div>
        </div>
    </form>
</div>
<script type="text/javascript">
    var parentObj = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
    // 判断输入框是否为空
    function checkForm(){
        if($('input[name=flag_name]').val() == ''){
            showErrorMsg('属性名称不能为空！');
            $('input[name=flag_name]').focus();
            return false;
        }
        if($('input[name=flag_attr]').val() == ''){
            showErrorMsg('属性值不能为空！');
            $('input[name=flag_attr]').focus();
            return false;
        }else{
            if($('input[name=flag_attr]').val().length<=1){
                showErrorMsg('属性值至少2个以上小写字母');
                $('input[name=flag_attr]').focus();
                return false;
            }
        }   
        layer_loading('正在处理');
        $.ajax({
            type : 'post',
            url : "{:U('ArchivesFlag/add')}",
            data : $('#post_form').serialize(),
            dataType : 'json',
            success : function(res){
                layer.closeAll();
                if(res.code == 1){
                    var _parent = parent;
                    _parent.layer.close(parentObj);
                    _parent.layer.msg(res.msg, {shade: layer_shade, time: 1000}, function(){
                        _parent.window.location.reload();
                    });
                }else{
                    showErrorMsg(res.msg);
                }
            },
            error: function(e){
                layer.closeAll();
                showErrorAlert(e.responseText);
            }
        });
    }
  $(document).ready(function () { 
        $('#flag_attr').on('input', function () {
            const inputValue = $(this).val();
            const validValue = inputValue.replace(/[^a-z]/g, '');
            if (inputValue!== validValue) {
                $(this).val(validValue);
            }
        });
    });
</script>
{include file="public/footer" /}